package com.lvan.controller.order;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lvan.bean.BaseException;
import com.lvan.bean.Order;
import com.lvan.bean.Page;
import com.lvan.controller.BaseController;
import com.lvan.service.interfaze.order.IOrderService;

@Controller
@RequestMapping("/order")
public class OrderController extends BaseController{
	
	private IOrderService orderService;
	
	@RequestMapping("/add")
	public String add(Order order) throws BaseException{
		orderService.add(order);
		return INDEX;
	}

	public IOrderService getOrderService() {
		return orderService;
	}

	public void setOrderService(IOrderService orderService) {
		this.orderService = orderService;
	}
	
	@RequestMapping(value = "/query")
	public String query(ModelMap model,Page page,Order order,HttpServletRequest request) {
		List<Order> os = orderService.query(order, page);
		model.put("data", os);
		return INDEX;
	}
	
	@RequestMapping(value="/delete")
	public void delete(String id, HttpServletRequest request) throws BaseException {
		this.orderService.delete(id);
	}
	
	@RequestMapping(value="/update")
	public String update(Order t, HttpServletRequest request) throws BaseException {
		this.orderService.update(t);
		return INDEX;
	}
	
}
